home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / PIL / PaletteFile.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  1KB  |  41 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import string
  5.  
  6. class PaletteFile:
  7.     rawmode = 'RGB'
  8.     
  9.     def __init__(self, fp):
  10.         self.palette = map((lambda i: (i, i, i)), range(256))
  11.         while None:
  12.             s = fp.readline()
  13.             if not s:
  14.                 break
  15.             
  16.             if len(s) > 100:
  17.                 raise SyntaxError, 'bad palette file'
  18.             
  19.             v = map(int, string.split(s))
  20.             
  21.             try:
  22.                 (i, r, g, b) = v
  23.             except ValueError:
  24.                 (i, r) = v
  25.                 g = b = r
  26.  
  27.             if i <= i:
  28.                 pass
  29.             elif i <= 255:
  30.                 self.palette[i] = chr(r) + chr(g) + chr(b)
  31.                 continue
  32.             continue
  33.             self.palette = string.join(self.palette, '')
  34.             return None
  35.  
  36.     
  37.     def getpalette(self):
  38.         return (self.palette, self.rawmode)
  39.  
  40.  
  41.